﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using GameEngine;

namespace GameBoardViewer.Animation
{
    internal class Slide2DMoveAnimation: Animation
    {
        protected Point _startPoint;
        protected Point _endPoint;

        public Slide2DMoveAnimation(Position figurePos, TimeSpan animationLength, Point startPoint, Point endPoint)
            : base(figurePos, animationLength)
        {
            _startPoint = startPoint;
            _endPoint = endPoint;
        }

        public Point GetCurrentPoint()
        {
            float delta = 0;
            if (GetAnimationDelta(out delta) == false)
            {
                return _endPoint;
            }

            int pathX = _endPoint.X - _startPoint.X;
            int pathY = _endPoint.Y - _startPoint.Y;

            int x = _startPoint.X + (int)((float)pathX * delta);
            int y = _startPoint.Y + (int)((float)pathY * delta);

            return new Point(x, y);
        }

    }
}
